#include <functional>
#include <memory>



namespace gallnut {
    
    struct Timer {
        using ptr = std::shared_ptr<Timer>;
        int socket_fd;
        int delay;
        std::function<void(int)> TimerFunc;
        int level_num;
        int slot_num;
        int start_point;
        Timer::ptr next;
        Timer::ptr prev;

        Timer(int fd, int d, std::function<void(int)> func)
            :socket_fd(fd)
            ,delay(d)
            ,TimerFunc(func)
            ,level_num(0)
            ,slot_num(0)
            ,start_point(0)
            ,next(nullptr)
            ,prev(nullptr) {

        }
    };

    class Slot {
    public:
        Slot(): slot_head(nullptr) {}

        void append_timer(Timer::ptr timer);

        void remove_timer(Timer::ptr timer);

        Timer::ptr take_one_timer();

        Timer::ptr take_all_timer();

        bool empty();
    private:
        Timer::ptr slot_head;
    };

}
